﻿using System;
using System.Collections.Generic;
using System.Text;
using FunctionalCLR.Core;

namespace FunctionalCLR.Shell {
    public class ContextParserFactory : AbstractParserFactory {

        private IContext context = null;

        public ContextParserFactory(IContext context)
            : base() {
            this.context = context;
        }

        public override Parser CreateParser(string expr) {
            Parser cp 
                = new ContextParser(expr, context);
            cp.ConstantManager 
                = DefaultDependencyManager.Instance.ConstantManager;
            cp.FunctionManager 
                = this.context.GetFunctionManager();
            cp.ParserFactory = this;
            cp.Context = this.context;

            return cp;
        }

        public override Parser CreateParser(string expr, object context) {
            return this.CreateParser(expr);
        }
    }
}